package com.ecnu.system.domain.dto.incubation;

import com.ecnu.common.utils.StringUtils;
import com.ecnu.system.domain.IncubationFactory;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import java.util.List;

@Data
public class IncubationFactoryDTO extends IncubationFactory {

    @ApiModelProperty("文献列表")
    private List<IncubationFileDTO> fileList;

    @AssertTrue(message = "报名开启时，报名时限不能为空")
    public boolean isCorrespEmail() {
        if (StringUtils.isNotBlank(getCorrespEmail())) {
            String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
            return getCorrespEmail().matches(emailRegex);
        }
        return true;
    }

}
